{extend name="public/layout" /}
{block name="head_css"}
    <link rel="stylesheet" href="/static/home/css/upload.css?v={$version}">
{/block}

{block name="main"}

    <!-- 中间内容区域 -->
    <div class="content-area middle-content inline-box">
        {include file='user/member_left_nav'/}
        <div class="right-content-box inline-block">
            <form id="form">
                <div class="pc-form-line inline-box">
                    <div class="title inline-block">类型：</div>
                    <div class="ibox inline-block">
                        <select style="width: 100%" name="engineering_type">
                            {foreach name="$type_list" item="item"}
                                <option {if condition="$vo.engineering_type eq $item.name"} selected {/if} value="{$item.id}">{$item.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>

                <div class="pc-form-line inline-box">
                    <div class="title inline-block">标题：</div>
                    <div class="ibox inline-block">
                        <input type="text" name="title" value="{$vo.title}" />
                    </div>
                </div>

                <div class="pc-form-line middle-title inline-box">
                    <div class="title inline-block">联系人：</div>
                    <div class="ibox inline-block">
                        <input type="text" name="contacts" value="{$vo.contacts}"  />
                    </div>
                </div>

                <div class="pc-form-line inline-box">
                    <div class="title inline-block">电话：</div>
                    <div class="ibox inline-block">
                        <input  name="mobile" value="{$vo.mobile}"/>
                    </div>
                </div>

                <div class="pc-form-line inline-box">
                    <div class="title inline-block">详情：</div>
                    <div class="ibox inline-block">
                        <textarea name="detail" rows="5">{$vo.detail}</textarea>
                    </div>
                </div>

                <div class="pc-form-line inline-box">
                    <div class="title inline-block">图片：</div>
                    <div class="ibox inline-block">
                        <div class="sam-image-uploader">
                            <input type="file" name="images" accept="image/jpeg,image/jpg,image/png" value="" />
                        </div>
                        {foreach name="vo.imgs" key="key" item="item"}
                            <div class="sam-image-shower" style="background-image: url({$item.path});">
                                <input name="img[{$key}]" type="hidden" value="{$item.path}">
                                <div class="sam-image-cross" onclick="deleteUploadImage(this);">删除</div>
                            </div>
                        {/foreach}
                    </div>
                </div>


                <button id="submit" type="button" class="submit-btn">提交</button>
                {if condition="$vo.id"}
                    <input type="hidden" name="id" value="{$vo.id}">
                {/if}
            </form>
        </div>
    </div>
    <!-- 中间内容区域 END -->
    <script>
        {if isset($vo) && is_array($vo.imgs)}
        var img_length = {:count($vo.imgs)};
        var img_index = {:count($vo.imgs)};
        {else}
        var img_length = 0;
        var img_index = 0;
        {/if}
        var max_img = 3;
        var token = '{$token}';
        var domain = '{$domain}';
        $('#submit').on('click',function(){
            var obj = $("#form").serializeArray();
            $.post('{$action}',obj,function(data){
                if(data.code != 1){
                    alert(data.msg);
                }else{
                    alert('发布成功');
                    self.location='{$back_url}';
                }
            });
        });
    </script>
    <script src="/static/home/js/qiniu.js"></script>
    <script src="/static/home/js/upload.js"></script>

{/block}